<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Diner - Salt Meal Backend</title>
  <script th:src="@{../js/onesalt.js}" src="../static/js/onesalt.js"></script>
  <link th:if="false" href="../static/css/bootstrap.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <div class="panel" th:with="isEdit=${type.equals('add') || type.equals('edit')}">
    <form class="form-horizontal" id="form" onSubmit="submitSearch();return false;" th:type="${type}">
      <input th:if="${type} != 'add'" type="hidden" name="kitchenId" th:value="${kitchen.kitchenId}" />
      <input th:if="${type} != 'add'" type="hidden" name="cook.cookId" th:value="${kitchen.cook.cookId}" />
      <div class="form-group">
        <label class="col-sm-2 control-label">餐厅ID</label>
        <div class="col-sm-10">
          <p class="form-control-static" th:text="${kitchen.sn}">CHN001</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">餐厅名字</label>
        <div class="col-sm-10">
          <p th:if="!${isEdit}" class="form-control-static" th:text="${kitchen.name}">餐厅1</p>
          <input th:if="${isEdit}" type="text" class="form-control" name="name" th:value="${kitchen.name}" value="" />
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">厨子ID</label>
        <div class="col-sm-10">
          <p class="form-control-static" th:text="${kitchen.cook.user.sn}">CHN001</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">厨子名字</label>
        <div class="col-sm-10">
          <p class="form-control-static" th:text="${kitchen.cook.user.name}">张三</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">所在城市</label>
        <div class="col-sm-10">
          <p th:if="!${isEdit}" class="form-control-static" th:text="${kitchen.city}">上海</p>
          <input th:if="${isEdit}" type="text" class="form-control" name="city" th:value="${kitchen.city}" value="" />
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">地址</label>
        <div class="col-sm-10">
          <p th:if="!${isEdit}" class="form-control-static" th:text="${kitchen.address}">张衡路1080号</p>
          <input th:if="${isEdit}" type="text" class="form-control" name="address" th:value="${kitchen.address}" value="" />
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">餐厅介绍</label>
        <div class="col-sm-10">
          <p th:if="!${isEdit}" class="form-control-static" th:text="${kitchen.introduction}">13800000000</p>
          <input th:if="${isEdit}" type="text" class="form-control" name="introduction" th:value="${kitchen.introduction}" value="" />
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">人均消费</label>
        <div class="col-sm-10">
          <p th:if="!${isEdit}" class="form-control-static" th:text="${kitchen.averageSpend}">13800000000</p>
          <input th:if="${isEdit}" type="text" class="form-control" name="averageSpend" th:value="${kitchen.averageSpend}" value="" />
        </div>
      </div>
      <div class="form-group" th:if="!${isEdit}">
        <label class="col-sm-2 control-label">申请时间</label>
        <div class="col-sm-10">
          <p class="form-control-static" th:text="${kitchen.cook.applyTime != null ? #calendars.format(kitchen.cook.applyTime, 'yy-MM-dd hh:mm') : ''}">2012-03-18 18:00</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">备注</label>
        <div class="col-sm-10">
          <p th:if="!${isEdit}" class="form-control-static" th:text="${kitchen.notes}">test1@163.com</p>
          <input th:if="${isEdit}" type="text" class="form-control" name="notes" th:value="${kitchen.notes}" value="" />
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-2 col-sm-offset-5">
          <input type="submit" class="form-control" th:value="${isEdit} ? '保存' : '编辑'" value="保存" />
        </div>
      </div>
    </form>
    <script>
    function submitSearch() {
      var type = $("#form").attr("type");
      var kitchenId = $("#form input[name='kitchenId']").first().attr("value");
      if (type == 'edit') {
        loadContent("./kitchens/" + kitchenId, $("#form").serializeArray());
      } else {
        loadContent("./kitchens/" + kitchenId + "?edit=true");
      }
    }
    </script>
  </div>
</body>
</html>